class Ticket < ActiveRecord::Base
  belongs_to :tracker

  has_many :entries, :autosave => true
  has_many :entry_fields, :through => :entries, :source => :field

  has_many :tasks

  def fields
    # self.tracker.fields + self.entry_fields
    field_ids = Array.new

    self.tracker.fields.each do |field|
      field_ids << field.id unless field_ids.include?(field.id)
    end

    self.entry_fields.each do |field|
      field_ids << field.id unless field_ids.include?(field.id)
    end

    Field.find(:all, field_ids)
  end

  def get_entry!(field)
    field.get_entry!(self)
  end

  
  # after_create :methodx
=begin
  private
    def methodx

    end
=end
  
end
